Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 2.6 NoSuchElementException in AA code. #11734

Merged
merged 1 commit into from
Jul 5, 2023

Conversation

asvitkine
Copy link
Contributor

Change Summary & Additional Notes

Fix 2.6 NoSuchElementException in AA code.

This would happen if a unit has special chars in its aaType, causing it to be evaluated as a regex instead of an exact match. This specifically broke the code pattern (e.g. in FiringGroupSplitterAa):

final List<String> typeAas = UnitAttachment.getAllOfTypeAas(aaUnits);
for (final String typeAa : typeAas) {
  final Collection<Unit> firingUnits =
      CollectionUtils.getMatches(aaUnits, Matches.unitIsAaOfTypeAa(typeAa));

Causing an empty firingUnits due to typeAa being evaluated as a regex. I checked all the callsites and verified none of them actually require the regex behavior.

Fixes: #11458

Release Note

This would happen if a unit has special chars in its aaType, causing it to be evaluated as a regex instead of an exact match.
This specifically broke the code pattern (e.g. in FiringGroupSplitterAa):

    final List<String> typeAas = UnitAttachment.getAllOfTypeAas(aaUnits);
    for (final String typeAa : typeAas) {
      final Collection<Unit> firingUnits =
          CollectionUtils.getMatches(aaUnits, Matches.unitIsAaOfTypeAa(typeAa));

Causing an empty `firingUnits` due to typeAa being evaluated as a regex.
I checked all the callsites and verified none of them actually require the regex behavior.

Fixes: triplea-game#11458
@asvitkine asvitkine merged commit 6711573 into triplea-game:master Jul 5, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2.6+a8157da: UnifiedInvocationHandler#invoke:57 - java.util.NoSuchElementException
1 participant